import hyRequest from '../index';
import { IAccount, IDataType, ILoginResult } from './types';

enum LoginApi {
  AccountLogin = '/login',
  LoginUserInfo = '/user/',
  UserMenus = '/user/role/'
}
// 登录
export function accountLoginRequest(account: IAccount) {
  return hyRequest.post<IDataType<ILoginResult>>({
    url: LoginApi.AccountLogin,
    data: account
  });
}

// 获取用户信息
export function requestUserInfoById(id: number) {
  return hyRequest.get<IDataType<any>>({
    url: LoginApi.LoginUserInfo + id,
    isShowLoading: false
  });
}

// 获取菜单
export function requestUserMenusById(id: number) {
  return hyRequest.get<IDataType>({
    url: LoginApi.UserMenus + id + '/menu',
    isShowLoading: false
  });
}
